export default function() {
    // ***初始化Cesium***/
    var viewer = new Cesium.Viewer("cesiumContainer", {
      shouldAnimate: true,
      selectionIndicator: false,
      infoBox: false,
      homeButton: true,
      timeline: false, //是否显示时间线控件
      animation: false, //是否显示动画控件
      navigationHelpButton: false,
      sceneModePicker: false,
      baseLayerPicker: true,
      imageryProvider: new Cesium.UrlTemplateImageryProvider({// 黑暗图层
        url: "http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png"
      }),
      // imageryProvider : new Cesium.OpenStreetMapImageryProvider({// 明亮图层
      //   url : '//a.tile.openstreetmap.org/'
      // })
    });
    // 定义场景和相机
    var scene = viewer.scene;
    var camera = scene.camera;

    //***配置相关***/
    viewer._cesiumWidget._creditContainer.style.display = "none"; // 隐藏版权信息
    viewer.resolutionScale = window.devicePixelRatio; // 调整分辨率
    // viewer.terrainProvider = Cesium.createWorldTerrain();// 开启地形
    // 是否开启抗锯齿
    scene.fxaa = true;
    scene.postProcessStages.fxaa.enabled = true;

    // ***相机位置***/
    var cameraDestination = new Cesium.Cartesian3(-2606600.492753127, 4436680.452993519, 3756277.3799475622);
    var cameraOrientation = {
      heading: 5.609409308752509,
      pitch: -0.5045891652781482,
      roll: 6.280899851629023
    }
    camera.setView({
      destination: cameraDestination,
      orientation: cameraOrientation
    });
    // 重写返回主页
    viewer.homeButton.viewModel.command.beforeExecute.addEventListener(function (commandInfo) {
      viewer.camera.flyTo({
        orientation: cameraOrientation,
        destination: cameraDestination
      });
      commandInfo.cancel = true
    })

    showLaLon();
    // 显示经纬度
    function showLaLon() {
      var entity = viewer.entities.add({
        label: {
          show: false,
          showBackground: true,
          font: "14px monospace",
          horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
          verticalOrigin: Cesium.VerticalOrigin.TOP,
          pixelOffset: new Cesium.Cartesian2(15, 0),
        },
      });
      var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
      handler.setInputAction(movement => {
        var cartesian = viewer.camera.pickEllipsoid(
          movement.endPosition,
          scene.globe.ellipsoid
        );
        if (cartesian) {
          var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
          var longitudeString = Cesium.Math.toDegrees(
            cartographic.longitude
          ).toFixed(5);
          var latitudeString = Cesium.Math.toDegrees(
            cartographic.latitude
          ).toFixed(5);

          entity.position = cartesian;
          entity.label.show = true;
          entity.label.text =
            "Lon: " +
            ("   " + longitudeString) +
            "\u00B0" +
            "\nLat: " +
            ("   " + latitudeString) +
            "\u00B0";
        } else {
          entity.label.show = false;
        }
      }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
    }

    // viewer返回给No01-init.vue
    return viewer;
}